package cn.gson.springmvc.controller;

import cn.gson.springmvc.model.pojos.Namem;
import cn.gson.springmvc.model.service.CshiService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class CshiController {
       @Autowired
       CshiService cshiService;

       @RequestMapping("/dept-list")
       @ResponseBody
       public Map<String,Object> namem(Integer currPage,Integer pageSize){
           Page<Object> obj = PageHelper.startPage(currPage, pageSize);
           List<Namem> deptList = cshiService.selectname();

           Map<String,Object> map = new HashMap<>();
           map.put("total",obj.getTotal());
           map.put("rows",deptList);
           return map;
       }
}